package org.adream.account.controller;

import java.util.Map;

import org.adream.account.entity.CategoryEntity;
import org.adream.account.service.ADreamServiceException;
import org.adream.account.service.CategoryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * 企业 政府 社会组织 类别管理页面
 * 
 * @author chenhaoyu
 *
 */
@Controller
public class CategoryController {
	
	private static final Logger logger = LoggerFactory.getLogger(CategoryController.class);
	
	@Autowired
	private CategoryService categoryService;

	//企业 政府 社会组织 类别展示页
	@RequestMapping(value = "/categoryPage", method = RequestMethod.GET)
	public ModelAndView category() {
		return new ModelAndView("/category/category");
	}

	//企业 政府 社会组织 类别增加页
	@RequestMapping(value = "/categoryAddPage", method = RequestMethod.GET)
	public ModelAndView categoryAdd() {
		return new ModelAndView("/category/category_add");
	}

	//企业 政府 社会组织 类别编辑页
	@RequestMapping(value = "/categoryEditPage", method = RequestMethod.GET)
	public ModelAndView categoryEdit(int categoryId) {
		ModelAndView mv = new ModelAndView("/category/category_edit");
		Map<String,Object> map = mv.getModel();
		CategoryEntity category = categoryService.queryCategoryById(categoryId);
		map.put("category", category);
		return mv;
	}
}